; Takes in a PNG and outputs an autocrop image with 50 px padding.
; See http://www.gimp.org/tutorials/Basic_Batch/ for helpful (though sparse) documentation

(define (crop-and-pad-pdb filename)
	 (let* 
		(
			(image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
			(drawable (car (gimp-image-get-active-layer image)))
		)
		
		(plug-in-autocrop RUN-NONINTERACTIVE image drawable)
		(let* 
			(
				(width (car (gimp-image-width image)))
				(height (car (gimp-image-height image)))
			)
			
			(let*
				(
					(new_width (- width 50))
					(new_height (- height 50))
				)
				
				(gimp-layer-scale drawable new_width new_height TRUE)
				(gimp-layer-resize-to-image-size drawable)
				(gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
			)
		)
	)
)

; (let* ((image (car (gimp-file-load 0 \"1lui.png\" \"1lui.png\")))(drawable (car (gimp-image-get-active-layer image))))